/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.wins.vertx.entity;

import io.vertx.core.json.JsonObject;

/**
 * Converter for {@link io.wins.vertx.entity.Purchase}.
 *
 * NOTE: This class has been automatically generated from the {@link io.wins.vertx.entity.Purchase} original class using Vert.x codegen.
 */
public class PurchaseConverter {

  public static void fromJson(final JsonObject json, final Purchase obj) {
    if (json.getValue("address") instanceof String) {
      obj.setAddress((String)json.getValue("address"));
    }
    if (json.getValue("areaName") instanceof String) {
      obj.setAreaName((String)json.getValue("areaName"));
    }
    if (json.getValue("count") instanceof Number) {
      obj.setCount(((Number)json.getValue("count")).intValue());
    }
    if (json.getValue("createdOn") instanceof Number) {
      obj.setCreatedOn(((Number)json.getValue("createdOn")).longValue());
    }
    if (json.getValue("customerId") instanceof String) {
      obj.setCustomerId((String)json.getValue("customerId"));
    }
    if (json.getValue("detail") instanceof String) {
      obj.setDetail((String)json.getValue("detail"));
    }
    if (json.getValue("itemId") instanceof String) {
      obj.setItemId((String)json.getValue("itemId"));
    }
    if (json.getValue("itemType") instanceof Number) {
      obj.setItemType(((Number)json.getValue("itemType")).intValue());
    }
    if (json.getValue("payType") instanceof String) {
      obj.setPayType((String)json.getValue("payType"));
    }
    if (json.getValue("price") instanceof Number) {
      obj.setPrice(((Number)json.getValue("price")).floatValue());
    }
    if (json.getValue("status") instanceof Number) {
      obj.setStatus(((Number)json.getValue("status")).intValue());
    }
    if (json.getValue("title") instanceof String) {
      obj.setTitle((String)json.getValue("title"));
    }
    if (json.getValue("total") instanceof Number) {
      obj.setTotal(((Number)json.getValue("total")).floatValue());
    }
    if (json.getValue("updatedOn") instanceof Number) {
      obj.setUpdatedOn(((Number)json.getValue("updatedOn")).longValue());
    }
  }

  public static void toJson(final Purchase obj, final JsonObject json) {
    if (obj.getAddress() != null) {
      json.put("address", obj.getAddress());
    }
    if (obj.getAreaName() != null) {
      json.put("areaName", obj.getAreaName());
    }
    json.put("count", obj.getCount());
    json.put("createdOn", obj.getCreatedOn());
    if (obj.getCustomerId() != null) {
      json.put("customerId", obj.getCustomerId());
    }
    if (obj.getDetail() != null) {
      json.put("detail", obj.getDetail());
    }
    if (obj.getId() != null) {
      json.put("id", obj.getId());
    }
    if (obj.getSellNo() != null) {
      json.put("sellNo", obj.getSellNo());
    }
    if (obj.getItemId() != null) {
      json.put("itemId", obj.getItemId());
    }
    json.put("itemType", obj.getItemType());
    if (obj.getPayType() != null) {
      json.put("payType", obj.getPayType());
    }
    json.put("price", obj.getPrice());
    json.put("status", obj.getStatus());
    if (obj.getTitle() != null) {
      json.put("title", obj.getTitle());
    }
    json.put("total", obj.getTotal());
    json.put("updatedOn", obj.getUpdatedOn());
  }
}